<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标题" prop="title">
        <el-input v-model="queryParams.title" placeholder="请输入标题" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable size="small">
          <el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel"
            :value="dict.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['receipt:exampleSubjectManagerAudit:add']">新增
        </el-button>
      </el-col>
      <el-col :span="1.5" >
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['receipt:exampleSubjectManagerAudit:edit']">修改
        </el-button>
      </el-col>
      <el-col :span="1.5" v-if="false">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['receipt:exampleSubjectManagerAudit:remove']">删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="exampleSubjectManagerAuditList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" v-if="false" />
      <el-table-column label="标题" align="center" prop="title" />
      <el-table-column label="类型" align="center" prop="type" :formatter="topictypeFormat" />
      <el-table-column label="审核状态" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column label="审核意见" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <div v-if="scope.row.status == '1'" style="display: inline;">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="ManagerAuditConsent(scope.row)"
              v-hasPermi="['receipt:exampleSubjectManagerAudit:Consent']">通过</el-button>
            <el-button size="mini" type="text" icon="el-icon-edit" @click="ManagerAuditReject(scope.row)"
              v-hasPermi="['receipt:exampleSubjectManagerAudit:Reject']">驳回</el-button>
          </div>
          <div style="display: inline;">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
              v-hasPermi="['receipt:exampleSubjectManagerAudit:edit']">修改
            </el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
              v-hasPermi="['receipt:exampleSubjectManagerAudit:remove']">查看
            </el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 题簇列表表单 -->
    <el-dialog :title="title1" :visible.sync="dialogVisible" width="500px" append-to-body>
      <div>
        <el-input v-model="cname" placeholder="请输入标题" clearable size="small" style="width:55%"></el-input>
        <el-button @click="czs()" style="margin-left: 15px;">搜索</el-button>
      </div>
      <el-table :data="clusteAuditList" @selection-change="handleSelectionChange1" @select="selectChange"
        ref="multipleTable" @row-click="handleRowClick" @select-all="selectAll" style="margin-top: 15px;">
        <!-- ref:'multipleTable'  -->
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="id" align="center" prop="id" v-if="false" />
        <el-table-column label="题簇类型" align="center" prop="clusteName" />
      </el-table>
      <pagination v-show="total>0" :total="total2" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="Cluste" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormT()">确 定</el-button>
        <el-button @click="cancelT">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 知识点列表表单 -->
    <el-dialog :title="title2" :visible.sync="ZSVisible" width="500px" append-to-body>
      <div>
        <el-input v-model="name" placeholder="请输入标题" clearable size="small" style="width:55%"></el-input>
        <el-button @click="zs()" style="margin-left:15px;">搜索</el-button>
      </div>
      <el-table :data="ZSAuditList" @selection-change="handleSelectionChange2" @select="selectChange2"
        ref="multipleTable" @row-click="handleRowClick2" @select-all="selectAll2" style="margin-top: 15px;">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="id" align="center" prop="id" v-if="false" />
        <el-table-column label="知识点类型" align="center" prop="title" />
      </el-table>
      <pagination v-show="total>0" :total="total1" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="ClusteZ" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormZ()">确 定</el-button>
        <el-button @click="cancelZ">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="title1" :visible.sync="open1" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="审核意见" prop="remark">
          <el-input v-model="remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改例题题目管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入标题" />
        </el-form-item>
        <el-form-item label="类型" prop="type">
          <el-select v-model="form.type" placeholder="请选择类型">
            <el-option v-for="dict in topictypeOptions" :key="dict.dictValue" :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="题簇类型" prop="subjectClusteId">
          <el-button @click="Cluste">选择题簇</el-button>
          <el-input v-model="this.idscluste" :disabled="true" v-if="false"></el-input>
          <el-input v-model="this.clusteName" :disabled="true" style="width: 55%;margin-left: 15px"></el-input>
        </el-form-item>
        <!-- 审核弹框 -->
        <el-form-item label="知识类型" prop="knowledgeManagerId">
          <el-button @click="ClusteZ">选择知识点</el-button>
          <el-input v-model="this.knowledgeId" :disabled="true" v-if="false"></el-input>
          <el-input v-model="this.knowledgeManager" :disabled="true" style="width: 55%;margin-left: 15px"></el-input>
        </el-form-item>
        <el-form-item label="难度" prop="diffictRatio">
          <el-input-number v-model="form.diffictRatio" placeholder="请输入难度" controls-position="right" />
        </el-form-item>
        <el-form-item label="重要性" prop="importRatio">
          <el-input-number v-model="form.importRatio" placeholder="请输入重要性" controls-position="right" />
        </el-form-item>
        <el-form-item label="基础分值" prop="baseRatio">
          <el-input-number v-model="form.baseRatio" placeholder="请输入基础分值" controls-position="right" />
        </el-form-item>
        <!-- 题目答案选项列表 -->
        <el-form-item label="选项A" prop="baseRatioA">
          <el-checkbox type="checkbox" v-model="checkboxA" style="margin-right: 15px" />
          <el-input v-model="baseRatioA" placeholder="请输入选择A答案" style="width: 55%" />
        </el-form-item>
        <el-form-item label="选项B" prop="baseRatioB">
          <el-checkbox type="checkbox" v-model="checkboxB" style="margin-right: 15px" />
          <el-input v-model="baseRatioB" placeholder="请输入选择B答案" style="width: 55%" />
        </el-form-item>
        <el-form-item label="选项C" prop="baseRatioC">
          <el-checkbox type="checkbox" v-model="checkboxC" style="margin-right: 15px" />
          <el-input v-model="baseRatioC" placeholder="请输入选择C答案" style="width:55%" />
        </el-form-item>
        <el-form-item label="选项D" prop="baseRatioD">
          <el-checkbox type="checkbox" v-model="checkboxD" style="margin-right: 15px" />
          <el-input v-model="baseRatioD" placeholder="请输入选择D答案" style="width:55%" />
        </el-form-item>
        <el-form-item label="选项E" prop="baseRatioE">
          <el-checkbox type="checkbox" v-model="checkboxE" style="margin-right: 15px" />
          <el-input v-model="baseRatioE" placeholder="请输入选择E答案" style="width:55%" />
        </el-form-item>
        <el-form-item label="选项F" prop="baseRatioF">
          <el-checkbox type="checkbox" v-model="checkboxF" style="margin-right: 15px" />
          <el-input v-model="baseRatioF" placeholder="请输入选择F答案" style="width:55%" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-if="isshow">确 定</el-button>
        <el-button @click="cancel" v-if="isshow">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import {
    listExampleSubjectManagerAudit,
    getExampleSubjectManagerAudit,
    delExampleSubjectManagerAudit,
    addExampleSubjectManagerAudit,
    updateExampleSubjectManagerAudit,
    exportExampleSubjectManagerAudit,
    ManageAuditConsent,
    ManageAuditReject
  } from "@/api/receipt/exampleSubjectManagerAudit";
  import {
    listCluste,
    selectName,
    selectStatus
  } from "@/api/receipt/subjectcluste";
  import {
    listManager,
    selectKmName,
    selectKnowledge
  } from "@/api/knowledge/knowledgeManager";
  export default {
    name: "ExampleSubjectManagerAudit",
    components: {},
    data() {
      var checkAge = (rule, knowledgeManagerId, callback) => {
        if (this.knowledgeId == "") {
          return callback(new Error('请选择知识点'));
        } else {
          callback();
        }
      };
      var checkAgecluster = (rule, subjectClusteId, callback) => {
        if (this.idscluste == null) {
          return callback(new Error('请选择题簇'));
        } else {
          callback();
        }
      };
      var diffictRatio = (rule, value, callback) => {
        if (value > 100) {
          return callback(new Error('难度不能大于100'));
        } else if (value <= 0) {
          return callback(new Error('难度不能小于1'));
        } else if (Number(value) + '' == 'NaN') {
          return callback(new Error('难度个数必须为数字'));
        } else {
          callback();
        }
      };
      var importRatio = (rule, value, callback) => {
        if (value > 100) {
          return callback(new Error('重要性不能大于100'));
        } else if (value <= 0) {
          return callback(new Error('重要性不能小于1'));
        } else if (Number(value) + '' == 'NaN') {
          return callback(new Error('重要性必须为数字'));
        } else {
          callback();
        }
      };
      var baseRatio = (rule, value, callback) => {
        if (value > 1000) {
          return callback(new Error('基础分值不能大于1000'));
        } else if (value <= 0) {
          return callback(new Error('基础分值不能小于1'));
        } else if (Number(value) + '' == 'NaN') {
          return callback(new Error('基础分值个数必须为数字'));
        } else {
          callback();
        }
      };
      var baseRatioA = (rule, value, callback) => {
        if (this.checkboxA == true && this.baseRatioA == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      var baseRatioB = (rule, value, callback) => {
        if (this.checkboxB == true && this.baseRatioB == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      var baseRatioC = (rule, value, callback) => {
        if (this.baseRatioC == true && this.baseRatioC == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      var baseRatioD = (rule, value, callback) => {
        if (this.baseRatioD == true && this.baseRatioD == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      var baseRatioE = (rule, value, callback) => {
        if (this.baseRatioE == true && this.baseRatioE == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      var baseRatioF = (rule, value, callback) => {
        if (this.baseRatioF == true && this.baseRatioF == "") {
          return callback(new Error('勾选必须要填写正确答案'));
        } else {
          callback();
        }
      };
      return {
        title2: "知识点选择",
        title1: "题簇选择",
        isshow: true,
        deptOptions: [],
        cname: null,
        name: null,
        ZSAuditList: [],
        status: null,
        remark: null,
        id: null,
        checkboxA: false,
        checkboxB: false,
        checkboxC: false,
        checkboxD: false,
        checkboxE: false,
        checkboxF: false,
        baseRatioA: "",
        baseRatioB: "",
        baseRatioC: "",
        baseRatioD: "",
        baseRatioE: "",
        baseRatioF: "",
        option: [],
        correctoption: [],
        handleSelectionList: [],
        clusteAuditList: [],
        idscluste: null,
        clusteName: null,
        knowledgeId: "",
        knowledgeManager: "",
        dialogVisible: false,
        ZSVisible: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        total1: 0,
        total2: 0,
        // 例题题目管理表格数据
        exampleSubjectManagerAuditList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        open1: false,
        // 类型 1选择题 2填空题字典
        topictypeOptions: [],
        // 审核状态 1未审核(默认) 2已审核字典
        statusOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          title: null,
          type: null,
          subjectClusteId: null,
          knowledgeManagerId: null,
          diffictRatio: null,
          importRatio: null,
          baseRatio: null,
          knowledgeScore: null,
          status: null,
          isDel: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          title: [{
            required: true,
            message: "请输入标题",
            trigger: "blur"
          }],
          type: [{
            required: true,
            message: "请输入类型",
            trigger: "blur"
          }],

          diffictRatio: [{
              required: true, //是否必填
              message: '难度不能为空', //规则
              trigger: 'blur' //何事件触发
            },
            {
              validator: diffictRatio,
              trigger: 'blur'
            },
          ],
          importRatio: [{
              required: true, //是否必填
              message: '重要性不能为空', //规则
              trigger: 'blur' //何事件触发
            },
            {
              validator: importRatio,
              trigger: 'blur'
            },
          ],
          baseRatio: [{
              required: true, //是否必填
              message: '基础分值不能为空', //规则
              trigger: 'blur' //何事件触发
            },
            {
              validator: baseRatio,
              trigger: 'blur'
            },
          ],
          subjectClusteId: [{
            validator: checkAgecluster,
            trigger: "blur"
          }],
          knowledgeManagerId: [{
            validator: checkAge,
            trigger: 'blur'
          }],
          baseRatioA: [{
            required: true,
            validator: baseRatioA,
            trigger: 'blur'
          }],
          baseRatioB: [{
            required: true,
            validator: baseRatioB,
            trigger: 'blur'
          }],
          baseRatioC: [{
            required: true,
            validator: baseRatioC,
            trigger: 'blur'
          }],
          baseRatioD: [{
            required: true,
            validator: baseRatioD,
            trigger: 'blur'
          }],
          baseRatioE: [{
            required: true,
            validator: baseRatioE,
            trigger: 'blur'
          }],
          baseRatioF: [{
            required: true,
            validator: baseRatioF,
            trigger: 'blur'
          }],
        }
      };
    },
    created() {
      this.getList();
      this.getDicts("dict_topictype").then(response => {
        this.topictypeOptions = response.data;
      });
      this.getDicts("sys_audit_status").then(response => {
        this.statusOptions = response.data;
      });
    },
    methods: {
      /** 查询例题题目管理列表 */
      getList() {
        this.loading = true;
        listExampleSubjectManagerAudit(this.queryParams).then(response => {
          this.exampleSubjectManagerAuditList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 类型 1选择题 2填空题字典翻译
      topictypeFormat(row, column) {
        return this.selectDictLabel(this.topictypeOptions, row.type);
      },
      // 审核状态 1未审核(默认) 2已审核字典翻译
      statusFormat(row, column) {
        return this.selectDictLabel(this.statusOptions, row.status);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.baseRatioA = "";
        this.baseRatioB = "";
        this.baseRatioC = "";
        this.baseRatioD = "";
        this.baseRatioE = "";
        this.baseRatioF = "";
        this.checkboxA = false;
        this.checkboxB = false;
        this.checkboxC = false;
        this.checkboxD = false;
        this.checkboxE = false;
        this.checkboxF = false;
        this.option = [];
        this.correctoption = [];
        this.knowledgeManager = "";
        this.knowledgeId = "";
        this.clusteName = null;
        this.idscluste = null;
        this.reset();
      },
      cancelT() {
        this.dialogVisible = false;
      },
      cancelZ() {
        this.ZSVisible = false;
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          title: null,
          topictype: null,
          subjectClusteId: null,
          knowledgeManagerId: null,
          diffictRatio: 30,
          importRatio: 30,
          baseRatio: 30,
          knowledgeScore: null,
          status: null,
          isDel: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null
        };
        this.resetForm("form");
      },
      /** 同意按钮操作 */
      ManagerAuditConsent(row) {
        this.open1 = true;
        this.id = row.id;
        //alert(this.id)
        this.status = 2;
      },
      cancel1() {
        this.open1 = false;
      },
      ManagerAuditReject(row) {
        this.open1 = true;
        this.id = row.id;
        this.status = 3;
      },
      submitForm1() {
        this.form.id = this.id;
        this.form.remark = this.remark
        if (this.status == 2) {
          this.form.status = this.status;
          ManageAuditConsent(this.form).then(response => {
            this.msgSuccess("审批已通过");
            this.remark = null;
            this.open1 = false;
            this.getList();
          });
        } else {
          this.form.status = this.status;
          ManageAuditReject(this.form).then(respon => {
            this.msgSuccess("审批已驳回");
            this.remark = null;
            this.open1 = false;
            this.getList();
          });
        }
      },
      czs() {
        if (this.cname.length == 0) {
          this.$confirm('请先输入搜索内容', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          });
        } else {
          selectName(this.cname).then(response => {
            this.dialogVisible = false;
            this.clusteAuditList = response;
            this.dialogVisible = true;
          });
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      handleSelectionChange1(selection) {
        //alert(selection[0].id+"+++++++++"+selection[0].clusteName)
        this.idscluste = selection[0].id
        this.clusteName = selection[0].clusteName
      },
      selectChange(selection, row) {
        if (selection.length > 1) {
          const del_row = selection.shift()
          this.$refs.multipleTable.toggleRowSelection(del_row, false)
        }
      },
      // 点击行触发，选中或不选中复选框
      handleRowClick(row, column, event) {
        this.$refs.multipleTable.toggleRowSelection(row)
        this.selectChange(this.handleSelectionList)
      },
      selectAll(selection) {
        if (selection.length > 1) {
          selection.length = 1
        }
      },
      handleSelectionChange2(selection) {
        this.knowledgeId = selection[0].id
        this.knowledgeManager = selection[0].title
      },
      selectChange2(selection, row) {
        if (selection.length > 1) {
          const del_row = selection.shift()
          this.$refs.multipleTable.toggleRowSelection(del_row, false)
        }
      },
      // 点击行触发，选中或不选中复选框
      handleRowClick2(row, column, event) {
        this.$refs.multipleTable.toggleRowSelection(row)
        this.selectChange(this.handleSelectionList)
      },
      selectAll2(selection) {
        if (selection.length > 1) {
          selection.length = 1
        }
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加例题题目管理";
      },
      zs() {
        if (this.name.length == 0) {
          this.$confirm('请先输入搜索内容', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          });
        } else {
          selectKmName(this.name).then(response => {
            this.ZSVisible = false;
            this.ZSAuditList = response;
            this.ZSVisible = true;
          });
        }
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getExampleSubjectManagerAudit(id).then(response => {
          
          this.form = response.data;
          this.option = response.data.option;
          this.correctoption = response.data.correctoption;
          if (this.option[0] != null) {
            this.baseRatioA = this.option[0];
          }
          if (this.option[1] != null) {
            this.baseRatioB = this.option[1];
          }
          if (this.option[2] != null) {
            this.baseRatioC = this.option[2];
          }
          if (this.option[3] != null) {
            this.baseRatioD = this.option[3];
          }
          if (this.option[4] != null) {
            this.baseRatioE = this.option[4];
          }
          if (this.option[5] != null) {
            this.baseRatioF = this.option[5];
          }
          this.clusteName = response.data.clusteName;
          this.knowledgeManager = response.data.zsName;
          this.knowledgeId=response.data.knowledgeManagerId;
          this.idscluste=response.data.subjectClusteId;
          this.isshow = true;
          this.open = true;
          for (var i = 0; i <= this.correctoption.length; i++) {
            if (this.correctoption[i] == this.baseRatioA && this.correctoption[i] != null) {
              this.checkboxA = true;
            }
            if (this.correctoption[i] == this.baseRatioB && this.correctoption[i] != null) {
              this.checkboxB = true;
            }
            if (this.correctoption[i] == this.baseRatioC && this.correctoption[i] != null) {
              this.checkboxC = true;
            }
            if (this.correctoption[i] == this.baseRatioD && this.correctoption[i] != null) {
              this.checkboxE = true;
            }
            if (this.correctoption[i] == this.baseRatioE && this.correctoption[i] != null) {
              this.checkboxD = true;
            }
            if (this.correctoption[i] == this.baseRatioF && this.correctoption[i] != null) {
              this.checkboxF = true;
            }
          }
          this.title = "修改例题题目管理";
        });
      },
      Cluste() {
        selectStatus(this.queryParams).then(response => {
          //alert(JSON.stringify(response))
          this.total2 = response.total;
          this.clusteAuditList = response.rows;
          this.dialogVisible = true
        });
      },
      ClusteZ() {
        selectKnowledge(this.queryParams).then(response => {
          this.total1 = response.total;
          this.ZSAuditList = response.rows;
          this.ZSVisible = true;
        });
      },
      submitFormT() {
        this.dialogVisible = false;
      },
      submitFormZ() {
        this.ZSVisible = false;
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              if (this.option.length > 0) {
                this.option = [];
                this.correctoption = [];
                if (this.baseRatioA.length > 0) {
                  this.option.push(this.baseRatioA)
                }
                if (this.baseRatioB.length > 0) {
                  this.option.push(this.baseRatioB)
                }
                if (this.baseRatioC.length > 0) {
                  this.option.push(this.baseRatioC)
                }
                if (this.baseRatioD.length > 0) {
                  this.option.push(this.baseRatioD)
                }
                if (this.baseRatioE.length > 0) {
                  this.option.push(this.baseRatioE)
                }
                if (this.baseRatioF.length > 0) {
                  this.option.push(this.baseRatioF)
                }
                if (this.checkboxA == true) {
                  this.correctoption.push(this.baseRatioA)
                }
                if (this.checkboxB == true) {
                  this.correctoption.push(this.baseRatioB)
                }
                if (this.checkboxC == true) {
                  this.correctoption.push(this.baseRatioC)
                }
                if (this.checkboxD == true) {
                  this.correctoption.push(this.baseRatioD)
                }
                if (this.checkboxE == true) {
                  this.correctoption.push(this.baseRatioE)
                }
                if (this.checkboxF == true) {
                  this.correctoption.push(this.baseRatioF)
                }
                this.form.option = this.option;
                this.form.correctoption = this.correctoption;
                //alert(this.option+"+++++"+this.correctoption)
                this.form.subjectClusteId = this.idscluste;
                this.form.knowledgeManagerId = this.knowledgeId;
              }
              updateExampleSubjectManagerAudit(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.baseRatioA = "";
                this.baseRatioB = "";
                this.baseRatioC = "";
                this.baseRatioD = "";
                this.baseRatioE = "";
                this.baseRatioF = "";
                this.checkboxA = false;
                this.checkboxB = false;
                this.checkboxC = false;
                this.checkboxD = false;
                this.checkboxE = false;
                this.checkboxF = false;
                this.option = [];
                this.correctoption = [];
                this.knowledgeManager = "";
                this.knowledgeId = "";
                this.clusteName = null;
                this.open = false;
                this.getList();
              });
            } else {
              this.form.subjectClusteId = this.idscluste;
              this.form.knowledgeManagerId = this.knowledgeId;
              if (this.baseRatioA.length > 0) {
                this.option.push(this.baseRatioA)
              }
              if (this.baseRatioB.length > 0) {
                this.option.push(this.baseRatioB)
              }
              if (this.baseRatioC.length > 0) {
                this.option.push(this.baseRatioC)
              }
              if (this.baseRatioD.length > 0) {
                this.option.push(this.baseRatioD)
              }
              if (this.baseRatioE.length > 0) {
                this.option.push(this.baseRatioE)
              }
              if (this.baseRatioF.length > 0) {
                this.option.push(this.baseRatioF)
              }
              if (this.checkboxA == true) {
                this.correctoption.push(this.baseRatioA)
              }
              if (this.checkboxB == true) {
                this.correctoption.push(this.baseRatioB)
              }
              if (this.checkboxC == true) {
                this.correctoption.push(this.baseRatioC)
              }
              if (this.checkboxD == true) {
                this.correctoption.push(this.baseRatioD)
              }
              if (this.checkboxE == true) {
                this.correctoption.push(this.baseRatioE)
              }
              if (this.checkboxF == true) {
                this.correctoption.push(this.baseRatioF)
              }
              this.form.option = this.option;
              this.form.correctoption = this.correctoption;
              addExampleSubjectManagerAudit(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.baseRatioA = "";
                this.baseRatioB = "";
                this.baseRatioC = "";
                this.baseRatioD = "";
                this.baseRatioE = "";
                this.baseRatioF = "";
                this.checkboxA = false;
                this.checkboxB = false;
                this.checkboxC = false;
                this.checkboxD = false;
                this.checkboxE = false;
                this.checkboxF = false;
                this.option = [];
                this.correctoption = [];
                this.knowledgeManager = "";
                this.knowledgeId = "";
                this.clusteName = "";
                this.idscluste = "";
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        this.reset();
        const id = row.id || this.ids
        getExampleSubjectManagerAudit(id).then(response => {
          this.form = response.data;
          this.option = response.data.option;
          this.correctoption = response.data.correctoption;
          //this.baseRatioA= "this.option[0];"
          if (this.option[0] != null) {
            this.baseRatioA = this.option[0];
          }
          if (this.option[1] != null) {
            this.baseRatioB = this.option[1];
          }
          if (this.option[2] != null) {
            this.baseRatioC = this.option[2];
          }
          if (this.option[3] != null) {
            this.baseRatioD = this.option[3];
          }
          if (this.option[4] != null) {
            this.baseRatioE = this.option[4];
          }
          if (this.option[5] != null) {
            this.baseRatioF = this.option[5];
          }
          this.clusteName = response.data.clusteName;
          this.knowledgeManager = response.data.zsName;
          this.isshow = false;
          this.open = true;
          for (var i = 0; i <= this.correctoption.length; i++) {
            if (this.correctoption[i] == this.baseRatioA && this.correctoption[i] != null) {
              this.checkboxA = true;
            }
            if (this.correctoption[i] == this.baseRatioB && this.correctoption[i] != null) {
              this.checkboxB = true;
            }
            if (this.correctoption[i] == this.baseRatioC && this.correctoption[i] != null) {
              this.checkboxC = true;
            }
            if (this.correctoption[i] == this.baseRatioD && this.correctoption[i] != null) {
              this.checkboxE = true;
            }
            if (this.correctoption[i] == this.baseRatioE && this.correctoption[i] != null) {
              this.checkboxD = true;
            }
            if (this.correctoption[i] == this.baseRatioF && this.correctoption[i] != null) {
              this.checkboxF = true;
            }
          }
          this.title = "查看例题题目";
        });
      },
    }
  };
</script>
